package com.lx.oms.controller.manager.impl;

import java.math.BigInteger;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.lx.oms.common.entity.Page;
import com.lx.oms.common.entity.Query;
import com.lx.oms.common.utils.Utils;
import com.lx.oms.controller.dao.InformationMapper;
import com.lx.oms.controller.entity.InformationEntity;
import com.lx.oms.controller.manager.InformationManager;

/**
 * 资讯
 *
 * @author houzhong
 * @date 2018年7月19日 下午12:00:08
 */
@Component("informationManager")
public class InformationManagerImpl implements InformationManager {

	@Autowired
	private InformationMapper informationMapper;
	

	@Override
	public List<InformationEntity> listInformation(Page<InformationEntity> page, Query search) {
		return informationMapper.listForPage(page, search);
	}

	@Override
	public int saveInformation(InformationEntity information) {
		if (information.getId() == null) {
			information.setId(Utils.id().toString());
		}
		return informationMapper.save(information);
	}

	@Override
	public InformationEntity getInformationById(BigInteger id) {
		InformationEntity information = informationMapper.getObjectById(id);
		return information;
	}

	@Override
	public int updateInformation(InformationEntity information) {
		return informationMapper.update(information);
	}

	@Override
	public int batchRemove(String[] id) {
		int count = informationMapper.batchRemove(id);
		return count;
	}
	
}
